﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using LM.Negocio.Objetos;

namespace LM.Repositorios.Maps
{
    public class ItemTabelaPrecoMap : EntityTypeConfiguration<ItemTabelaPreco>
    {
        public ItemTabelaPrecoMap()
        {
            this.HasKey(c => c.Id);
            this.Property(c => c.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).HasColumnName("Id");

            this.Property(c => c.CustoPeriodo).HasColumnName("CustoPrimeiroPeriodo").IsRequired();
            this.Property(c => c.Periodo).HasColumnName("Periodo").IsRequired();
            this.Property(c => c.CustoAdicional).HasColumnName("CustoAdicional");
            this.Property(c => c.PeriodoAdicional).HasColumnName("PeriodoAdicional");

            HasMany(p => p.DiasSemanaItemTabelaPrecos)
                .WithRequired(s => s.ItemTabela)
                .HasForeignKey(s => s.IdItemTabelaPreco).WillCascadeOnDelete(true);

            this.ToTable("ITEMTABELAPRECO");
        }
    }
}
